<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div{
            width: 300px;
            height: 300px;
            background-color: goldenrod;
        }


    </style>
</head>
<body>
    <div>
        
    </div>

    <script>
        const divObj = document.querySelector("div")
        /* 
            resize：浏览器窗口会触发该事件
         */
        window.addEventListener("resize",function(){
            console.log(window.innerWidth)
            console.log(window.innerHeight)
            /* 
                如果当前的窗口的宽度小于等于600px，就隐藏页面的div
             */
             if(window.innerWidth <=600){
                 divObj.style.display = 'none';
             }else{
                 divObj.style.display = 'block'
             }
        })
    </script>
</body>
</html>